package com.thread.thread3;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author : leimingchao
 * @date Date : 2021年11月30日 20:07
 */
public class ThreadTest3 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        System.out.println("主线程开始");
        Thread03 thread03 = new Thread03();
        FutureTask<String> futureTask = new FutureTask<>(thread03);
        Thread thread = new Thread(futureTask);
        thread.start();
        System.out.println("主线程hahaha");
        //获取异步运行的结果
        //获取结果会等待执行完
        String s = futureTask.get();
        System.out.println("异步获取到的结果是：" + s);
        System.out.println("主线程结束");
    }
}
